$.ajax({
	type: "get",
	url: "https://devapi.qweather.com/v7/weather/now?key=b15e71096d6541cab96ec0f8ed42ac2d&location=101270107",
	dataType: "json",
	success: function(data){
		console.log(data)
		console.log(data.updateTime)

		var now = data.now;
		var theTq = "<p>天气更新时间：" + data.updateTime + "</P><p>今日为："+ now.temp + "&#8451;," + data.now.text + "</p><div><img src='../images/colortq/" + now.icon + ".png' /></div><p>风速为：" + now.windSpeed + "公里/小时</p><p>降雨量为：" + now.precip + "</p><p>相对湿度：" + now.humidity + "</p>";
		$(".boxLeftTop").append(theTq)
		
		var bc = now.icon;
		console.log(bc)

		// 通过天气代码更换背景
		if(bc == 100 || bc == 150)$(".boxLeftTop").css({"background":"url(../images/tianqi/qt.png) center center no-repeat","backgroundSize":"cover"});

		if(bc == 104 || bc == 154)$(".boxLeftTop").css({"background":"url(../images/tianqi/yin.png) center center no-repeat","backgroundSize":"cover"});

		if(bc == 302 || bc == 303 || bc == 304)$(".boxLeftTop").css({"background":"url(../images/tianqi/ly.png) center center no-repeat","backgroundSize":"cover"});

		if(bc == 101 || bc == 102 || bc == 103 || bc == 153)$(".boxLeftTop").css({"background":"url(../images/tianqi/dy.png) center center no-repeat","backgroundSize":"cover"});

		if(bc == 300 || bc == 305 || bc == 306 || bc == 307 || bc == 308 || bc == 309 || bc == 310 || bc == 311 || bc == 312 || bc == 313 || bc == 314 || bc == 315 || bc == 316 || bc == 317 || bc == 318 || bc == 399 || bc == 350 || bc == 351)$(".boxLeftTop").css({"background":"url(../images/tianqi/yt.png) center center no-repeat","backgroundSize":"cover"});
	}
});




$.ajax({
	type: "get",
	url: "../json/indexDiv.json",
	dataType: "json",
	success: function(data){
		console.log(data)

		// 根据索引渲染页面
		doChangeBooks(data[0],$("#section"))
		doChangeBooks(data[1],$("#history"))
		doChangeBooks(data[2],$("#masterwork"))
		doChangeBooks(data[3],$("#philosophy"))

		function doChangeBooks(obj,id){
			for(var i in obj){
				for(var j in obj[i]){
					var thisBooks = "<div><a href='" + obj[i][j].url + "'><img src='" + obj[i][j].img + "' /></div>"; 
					id.append(thisBooks);
				}
			}
		}
	}
});